home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STFLSTL.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  1.1 KB  |  35 lines

  1. #include <graphics.h>
  2. #include <stdlib.h>
  3.  
  4. main()
  5. {
  6.    int graphdriver = DETECT, graphmode;
  7.    int maxcolor, color, pattern;
  8.    char buffer1[80], buffer2[80];
  9.  
  10. /* Initialize the graphics system */
  11.    initgraph(&graphdriver, &graphmode, "c:\\turboc");
  12. /* Now keep switching background colors randomly */
  13.    maxcolor = getmaxcolor();
  14. /* Initialize random number generator */
  15.    randomize();
  16.    outtextxy(10,20, "Demonstrating setfillstyle");
  17.    outtextxy(10,30, "Press any key to exit");
  18.    while (!kbhit())
  19.    {
  20.        color = random(maxcolor);
  21.        pattern = random(11);
  22.        setfillstyle(pattern, color);
  23.        bar(50,50, 150,100);
  24.        sprintf(buffer1, "Fill color %2d", pattern);
  25.    /* Erase the area where color number will be shown */
  26.        setfillstyle(EMPTY_FILL, color);
  27.        bar(50,100, 50+textwidth(buffer1), 100+3*textheight("H"));
  28.        outtextxy(50,100+textheight("H"), buffer1);
  29.        outtextxy(50,100+2*textheight("H"), buffer2);
  30.        delay(1000);  /* Pause for 1 second */
  31.    }
  32. /* Wait for 1 second, then exit */
  33.    delay(1000);
  34.    closegraph();
  35. }